package com.qfedu.springmvc02.controller;


import com.qfedu.springmvc02.entity.User;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/json")
public class JsonController {


    @RequestMapping("test1")
    public User test1(){
        User user = new User();
        user.setName("kkk1");
        user.setPassword("1234");
        return user;
    }


    @GetMapping("test2")
    public User test2(){
        User user = new User();
        user.setName("kkk2");
        user.setPassword("1234");
        return user;
    }


    @RequestMapping({"test3","test4"})
    public User test3(){
        User user = new User();
        user.setName("kkk34");
        user.setPassword("1234");
        return user;
    }

    @RequestMapping(value = "test5",produces ="text/html;charset=utf-8")
    public String test5(){
        return "王";
    }


    @RequestMapping("test6")
    public User test6(@RequestBody User user){
        System.out.println(user);
        return user;
    }

}
